import { Cookies } from 'quasar';

/**
 * token 键值
 */
const TOKEN_KEY = 'fn-admin-token-quasar';

/**
 * token 本地过期时间
 */
const TOKEN_EXPIRE_SECONDS = 24 * 60 * 60;

export function getToken(): string {
  return Cookies.get(TOKEN_KEY);
}

export function setToken(token: string): void {
  const expires = new Date(new Date().getTime() + TOKEN_EXPIRE_SECONDS * 1000);
  Cookies.set(TOKEN_KEY, token, { expires });
}

export function removeToken(): void {
  return Cookies.remove(TOKEN_KEY);
}
